package cn.jinbyte.web.annotation;

import cn.jinbyte.core.handler.crypt.CryptHandler;
import cn.jinbyte.core.handler.crypt.Sm4CryptHandler;
import cn.jinbyte.web.resolver.CryptPropArgResolver;
import cn.jinbyte.web.serialize.CryptPropDeserializer;
import cn.jinbyte.web.serialize.CryptPropSerializer;
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Crypt序列化属性，用于标注属性或方法参数的序列化
 *
 * @author jinty
 * @see CryptPropDeserializer
 * @see CryptPropSerializer
 * @see CryptPropArgResolver
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@JacksonAnnotationsInside
@JsonDeserialize(using = CryptPropDeserializer.class)
@JsonSerialize(using = CryptPropSerializer.class)
public @interface CryptProp {
    /**
     * 加解码处理类
     */
    Class<? extends CryptHandler> handler() default Sm4CryptHandler.class;
}
